<?php

namespace App\Services;

class DataChange
{
    public static function priceScope($price_scope_id)
    {
        if ($price_scope_id == 1 || !isset($price_scope_id)) {
            $between = [0, 9223372036854775807];
        } else if ($price_scope_id == 2) {
            $between = [0, 100000];
        } else if ($price_scope_id == 3) {
            $between = [200000, 300000];
        } else if ($price_scope_id == 4) {
            $between = [300000, 500000];
        } else if ($price_scope_id == 5) {
            $between = [500000, 1000000];
        } else if ($price_scope_id == 6) {
            $between = [10000000, 9223372036854775807];
        }
        return $between;
    }

    public static function diaryList($data)
    {
        $time = time();//现在时间戳
        foreach ($data as $k => $v){
            if($time-strtotime($v['created_at']) < 60){
                $data[$k]['time'] = '刚刚';
            }
            if($time-strtotime($v['created_at']) > 60){
                $data[$k]['time'] = '1分钟前';
            }
            if($time-strtotime($v['created_at']) > 60*5){
                $data[$k]['time'] = '5分钟前';
            }
            if($time-strtotime($v['created_at']) > 7200){
                $data[$k]['time'] = '2小时前';
            }
            if($time-strtotime($v['created_at']) > 86400){
                $data[$k]['time'] = '1天前';
            }
            if($time-strtotime($v['created_at']) > 259200){
                $data[$k]['time'] = '3天前';
            }
            if($time-strtotime($v['created_at']) > 604800){
                $data[$k]['time'] = '一周前';
            }
            if($time-strtotime($v['created_at']) > 1209600){
                $data[$k]['time'] = '两周前';
            }
            if($time-strtotime($v['created_at']) > 1814400){
                $data[$k]['time'] = '三周前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4){
                $data[$k]['time'] = '一个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*2){
                $data[$k]['time'] = '两个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*3){
                $data[$k]['time'] = '三个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*4){
                $data[$k]['time'] = '四个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*5){
                $data[$k]['time'] = '五个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*6){
                $data[$k]['time'] = '六个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*7){
                $data[$k]['time'] = '七个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*8){
                $data[$k]['time'] = '八个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*9){
                $data[$k]['time'] = '九个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*10){
                $data[$k]['time'] = '十个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*11){
                $data[$k]['time'] = '十一个月前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*12){
                $data[$k]['time'] = '一年前';
            }
            if($time-strtotime($v['created_at']) > 60*60*24*7*4*12*2){
                $data[$k]['time'] = date('Y-m-d',strtotime($v['created_at']));
            }
        }
        return $data;
    }
}
